include_directories(include)

if (WIN32)
  set(MAINFILE
    src/win32/oswindow_win32.cpp include/copi_oswindow.h
    src/win32/imgui_impl_dx11.h src/win32/imgui_impl_dx11.cpp
    src/win32/imgui_impl_win32.h src/win32/imgui_impl_win32.cpp)

  find_package(DirectX11 REQUIRED)
endif()

set(UISOURCEFILE
  src/imgui_colorbutton.cpp
  src/copi_os_window_warp.c src/copi_ui.cpp)

find_package(imgui CONFIG REQUIRED)
find_package(lua REQUIRED)
find_package(Stb REQUIRED)

# imgui 建议不要作为动态链接库的形式使用, 所以用静态连接
add_library(UI STATIC ${MAINFILE} ${UISOURCEFILE})
# add_library(UI ${LIBRARY_BUILD_TYPE} ${MAINFILE} ${UISOURCEFILE})
# add_library(UI MODULE ${MAINFILE} ${UISOURCEFILE})

target_link_libraries(UI
  PUBLIC ${LUA_LIBRARIES}
  PRIVATE imgui::imgui)

if (WIN32)
  target_link_libraries(UI
    PRIVATE ${Stb_INCLUDE_DIR}
    PRIVATE ${DirectX11_LIBRARY})
endif()

target_include_directories(UI
  INTERFACE ${LUA_INCLUDE_DIR})

set_target_properties(UI PROPERTIES
  #  RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/dist" # 做为静态链接库不需要输出目录
  CXX_STANDARD 20 C_STANDARD 99)
